# coding:utf8
import findspark

findspark.init()
from pyspark import SparkConf, SparkContext

if __name__ == '__main__':
    conf = SparkConf().setAppName("test").setMaster("local[*]")
    sc = SparkContext(conf=conf)

    rdd = sc.parallelize([1, 2, 3, 4, 5, 6, 7, 8, 9], 3)
    print(rdd.fold(10, lambda a, b: a + b))
# 分区1：10+6=16
# 分区2:10+15=25
#分区3：10+24=34
#总共：85